package com.bbx.flink.dataStream_api_all.CDC;

import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.table.api.bridge.java.StreamTableEnvironment;

public class FlinkCDCTableDemo {

    public static void main(String [] args) throws Exception {

        //执行环境
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.setParallelism(1);

        //获取table Env
        StreamTableEnvironment tableEnv = StreamTableEnvironment.create(env);

        String test1Sql="        CREATE TABLE test1 (\n" +
                "                id INT,\n" +
                "                name STRING\n" +
                "                ) WITH (\n" +
                "                'connector' = 'mysql-cdc',\n" +
                "                'hostname' = '192.168.10.7',\n" +
                "                'port' = '3306',\n" +
                "                'username' = 'root',\n" +
                "                'password' = '123456',\n" +
                "                'database-name' = 'maxwell_test1',\n" +
                "                'table-name' = 'test1')";
        tableEnv.executeSql(test1Sql);


        String querySQl = "select * from test1";
        tableEnv.executeSql(querySQl).print();

    }





}
